programming4us
           
 
 
SQL Server

SQL Server Integration Services : Running the SSIS Wizard

- Free product key for windows 10
- Free Product Key for Microsoft office 365
- Malwarebytes Premium 3.7.1 Serial Keys (LifeTime) 2019
11/28/2010 11:45:47 AM
The SSIS Wizard is a streamlined interface solely used to generate SSIS packages for importing or exporting data. It is really quite powerful and provides an easy but sophisticated way to move data from or to any OLE DB, ODBC, or text source to another OLE DB, ODBC, or text source. You can also define simple or complex data transformations using the many options provided by the wizard. The wizard can also copy database schema, but the transfer of all other database objects, such as indexes, constraints, users, permissions, stored procedures, and so on, is supported only between SQL Server 7.0 and higher SQL Servers.

The SSIS Import/Export Wizard takes the user through five basic steps for both imports and exports:

1.
Select/identify the data source (source).

2.
Select/identify the destination (target).

3.
Select the data copy and transformation type. The options are to copy data with or without the schema, to move data based on a query, or to transfer objects and data between data stores.

4.
Define any data transformations, if required.

5.
Save, schedule, and execute the package.

Let’s walk through a quick wizard sequence and create a package that fulfills the “Hot Customers Plus” data movement/transformation requirement. You will be pulling and transforming data from the AdventureWorks2008 database and pushing it to another database on the same server instance (SQL08DEV01 in this example). So, first, you need to create a database named UnleashedDataMart as the target database to hold the new HotCustomersPlus table you will be creating with SSIS. Remember that you use the SSIS Wizard for simple package creations (or data transfers). Nothing fancy here. To get started, here’s what you do:

1.
Fire up the SSIS Wizard from within SSMS by either right-clicking the database branch for the database from which you will be exporting data or right-clicking in the summary pane for that same database (as shown in Figure 1). If you select the Tasks option, you are given the option of either importing or exporting data. You want to export data from this database, so choose the Export Data option.

Figure 1. Invoking the Export Data Wizard.


2.
Work through the steps of the SSIS Wizard. The initial step is identifying the source for the data. In this example, you need to choose a valid SQL Server and source database (in this example, DBARCH-LT2\SQL08DE01 for the server and AdventureWorks2008 for the database). In addition, you must provide the appropriate access credentials (Windows authentication or SQL Server authentication) for this source SQL Server. You have a few options of exactly what access mechanism to use (to this data source). Choose the SQL Native Client connection method (see Figure 2).



Figure 2. Identifying the SSIS source database and server locations.


3.
Next is the data “destination” specification (the target). We had already created a new database (called UnleashedDataMart) for this purpose before we started and use that for this example. Our example uses the same SQL Server instance of DBARCH-LT2\SQL08DE01, using the connection method to this SQL Server instance of SQL Native Client, and the previously mentioned database of UnleashedDataMart (as shown in Figure 3). We also use Windows Authentication. You are finished with this window, so click Next.

Figure 3. Identifying the SSIS destination database and server locations.


4.
The next step in the wizard asks if you will be pulling source data from one or more tables (or views) or if you will be specifying a SQL query to pull data from the source. For this example, select the Write a Query to Specify the Data to Transfer option because this approach best fits the requirement specified earlier (see Figure 4).

Figure 4. Specifying to use tables or a query for data transfer from the data source.


5.
In the next step in the wizard, create your custom SQL statement that will be used to select data from the source database. We have provided a fairly complex SQL query that selects (and joins) data from six tables in the AdventureWorks2008 database to fulfill the data requirement for this example. This SQL Statement is available on this book’s CD. In this step of the wizard, enter the following query:

SELECT  a.CustomerID,
e.name as CustomerName,
a.CustomerType,
a.TerritoryID,
d.name as TerritoryName,
c.ProductID,
f.name as ProductName,
sum(c.LineTotal) as YTDSalesTotal
FROM
[sales].[Customer] a
INNER JOIN [sales].[SalesOrderHeader] b
ON a.customerid = b.customerid
INNER JOIN [sales].[SalesOrderDetail] c
ON b.SalesOrderID = c.SalesOrderID
INNER JOIN [sales].[SalesTerritory] d
ON a.TerritoryID = d.TerritoryID
INNER JOIN [sales].[Store] e
ON a.customerid = e.customerid
INNER JOIN [Production].[Product] f
ON c.productID = f.ProductID
WHERE b.orderdate >= '2004-01-01 00:00:00.000'
GROUP BY a.customerID,
e.name,
a.CustomerType,
a.TerritoryID,
d.name,
c.ProductID,
f.name
HAVING sum(c.LineTotal) > 5000
ORDER BY d.name,
e.name



In this window, you can select a query from a file by clicking the Browse button to search for this file, or you can simply start coding directly in the window. You can click the Parse button to guarantee that the SQL statement has valid syntax and form (see Figure 5). You can test it (preview the data) in the next wizard step.

Figure 5. Providing a SQL query to select data from a data source.


However, if you chose to copy data directly from the database tables (and not use a SQL query), you would be provided a list of tables and views from the source database and would be able to map one or more of these tables to tables on the destination database. Figure 6 shows how this Select Source Tables and Views window would look.

Figure 6. Mapping source tables and views to a destination.


6.
Rename the destination table by changing [dbo].[Query] to [UnleashedDataMart].[dbo].[HotCustomersPlus] (see Figure 7). All subsequent references to this destination target will be what you want.

Figure 7. Source query mapping to a destination.


7.
Click the Preview button on this dialog to actually execute the SQL query specified in step 5. Figure 8 shows the Preview Data results of the custom SQL query. Close this data preview window when you are finished reviewing the data results.

Figure 8. Previewing the data from a SQL query.


8.
Click the Edit Mappings button to see the details of the column-level mappings being defined. At this point, you can further subset the columns, change data types, use precision or scale change, and/or not have a column mapped during the data transformation. As you can see in Figure 9, the Source and Destination columns are side by side, and when you click a column name, you can adjust what you want to occur (such as ignore or map to the column). In addition, at the object level, you can have the table created at the destination, have it truncate the data in an existing table at the destination, or append data to existing data at the destination. For this example, choose to completely drop and re-create the destination table each time. You are basically done creating the logic and data mappings for this simple data transformation.

Figure 9. Column Mappings options.


9.
If you want, click the Edit SQL button in the Column Mappings dialog. A CREATE TABLE SQL statement appears, and you can modify it if you want (see Figure 10). You don’t need to do any further changes at this time, however.

Figure 10. Manually customizing the default CREATE TABLE statement.


10.
In the Save and Run Package dialog that appears, choose Run Immediately and Save SSIS Package. Save the SSIS package in SQL Server in the msdb SQL Server database (see Figure 11). It is also possible to save the SSIS package in a structured storage file at the filesystem level (in a .dtsx file).

Figure 11. Options for executing and saving SSIS packages.


11.
In the Save SSIS Package dialog, you specify the name of the package, description of the package, and location where the package is to be stored. For this example, specify the name “HotCustomersPlus” for the SSIS package, as shown in Figure 12.

Figure 12. Saving a package for reuse.


12.
When the SSIS Wizard displays the Complete the Wizard dialog, summarizing all the actions to be taken, carefully review the list and then click Finish when you are ready to proceed. After you click Finish, the wizard’s execution console appears, as shown in Figure 13. This console shows all the steps taken, the status of these steps, and informational detail, as required. In Figure 13 note the Copying to [Unleashed].[dbo].[HotCustomersPlus] table message that 943 rows were transferred. There is an Error in the step above the row copy that refers to the Drop of the target table not being found. This was expected since the table never existed before, this was the first time it would have been created. Subsequent runs will not have this error. Following this particular “Copying” step are the simple post execute and cleanup actions for the package.

Figure 13. SSIS package initialization, saving, and execution.


If you would like, you can also query the system catalog table that contains the metadata for packages. In this case, the system table [msdb].[dbo].[sysssispackages] contains this metadata for SSIS packages starting with SQL Server 2005, and going forward. The following simple SQL query shows the metadata entry for the package you just created:

 

SELECT * FROM [msdb].[dbo].[sysssispackages]

The results look like this:

Name             ID         Description         Datetime
HotCustomersPlus 025EBC25... Weekly datamart updates... 2009-11-01 ...

Figure 14 shows the execution tasks for doing straight table copying (transferring) using SSIS packages of the tables to create a quick-and-dirty (refreshable) data mart. This method of spinning off data quickly is very useful, and it fits our requirements.

Figure 14. An SSIS package straight table copy/transfer example.


Other -----------------
- SQL Server Integration Services : A Data Transformation Requirement
- SQL Server 2008 : SSIS Tools and Utilities
- SQL Server 2008 : SSIS Architecture and Concepts
- SQL Server 2008 : SQL Server Integration Services - SSIS Basics
- Defensive Error Handling : Using Transactions and XACT_ABORT to Handle Errors
- Managing Security Within the Database Engine : Securables
- Managing Security Within the Database Engine : Database Security
- Managing Security Within the Database Engine : Creating SQL Server Principals
- SQL Server 2008 : Performance Tuning - Locks, Blocking, and Deadlocks
- SQL Server 2008 : Performance Tuning - Tracing
- SQL Server 2008 : Implementing Error Handling - Managing and Raising User-Defined Errors
- SQL Server 2008 : Implementing Error Handling - Understanding Errors
- Implementing SQL Server Objects Using Managed Code (part 2)
- Implementing SQL Server Objects Using Managed Code (part 1)
- Encryption Catalog Views
- Built-In Cryptographic Functions
- SQL server 2008 : Managing Security - Permissions
- SQL server 2008 : Managing Security - Schemas
- SQL server 2008 : Managing Security - Users
- SQL server 2008 : Managing Security - Roles
 
 
 
Top 10
 
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 2) - Wireframes,Legends
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 1) - Swimlanes
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Formatting and sizing lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Adding shapes to lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Sizing containers
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 3) - The Other Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 2) - The Data Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 1) - The Format Properties of a Control
- Microsoft Access 2010 : Form Properties and Why Should You Use Them - Working with the Properties Window
- Microsoft Visio 2013 : Using the Organization Chart Wizard with new data
- First look: Apple Watch

- 3 Tips for Maintaining Your Cell Phone Battery (part 1)

- 3 Tips for Maintaining Your Cell Phone Battery (part 2)
programming4us programming4us